package com.lxh.singleton;

/**
 * 单例模式
 * Create by lxh on 2020/2/13
 */
public class Main {
    public static void main(String[] args) {
        // 单例模式
        Emperor emperor = Emperor.getInstance();
        System.out.println(emperor.hashCode());

        Emperor emperor1 = Emperor.getInstance();
        System.out.println(emperor1.hashCode());

        // 多例模式
        ManyEmperor manyEmperor = ManyEmperor.getInstance();
        ManyEmperor manyEmperor1 = ManyEmperor.getInstance();
        ManyEmperor manyEmperor2 = ManyEmperor.getInstance();
        ManyEmperor manyEmperor3 = ManyEmperor.getInstance();

        System.out.println(manyEmperor.hashCode());
        System.out.println(manyEmperor1.hashCode());
        System.out.println(manyEmperor2.hashCode());
        System.out.println(manyEmperor3.hashCode());
    }
}
